/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.gastronomico.demo.web;

import com.gastronomico.demo.domain.Promocion;
import com.gastronomico.demo.service.PromocionService;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

/**
 *
 * @author MIGUELANGEL
 */
@Controller
public class PromocionListaController {

    @Autowired
    PromocionService service;

    @RequestMapping(value = "/promocionLista.htm", method = RequestMethod.GET)
    public ModelAndView Promocion(HttpServletRequest req){
        ModelAndView mav = new ModelAndView("promocionLista");
        int id = Integer.parseInt(req.getParameter("id"));
        List<Promocion> promocionLista = service.obtenerPromociones(id);
        System.out.println("PROMOCION:" + promocionLista.size());
        mav.addObject("promocionLista", promocionLista);
        return mav;
    }

}
